import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm';
import { BaseEntity } from './base.entity';
import { User } from './user.entity';
import { Task } from './task.entity';

@Entity('files')
export class File extends BaseEntity {
  @Column({ length: 255 })
  originalName: string;

  @Column({ length: 255 })
  filename: string;

  @Column({ length: 255 })
  path: string;

  @Column({ length: 100 })
  mimeType: string;

  @Column({ type: 'int' })
  size: number;

  @Column({ length: 255, nullable: true })
  description: string;

  @ManyToOne(() => User, { onDelete: 'SET NULL' })
  @JoinColumn({ name: 'uploaderId' })
  uploader: User;

  @Column({ type: 'uuid', nullable: true })
  uploaderId: string;

  @ManyToOne(() => Task, task => task.files, { onDelete: 'CASCADE' })
  @JoinColumn({ name: 'taskId' })
  task: Task;

  @Column({ type: 'uuid', nullable: true })
  taskId: string;
} 